package me.zhengjie.modules.loan.domain;

import me.zhengjie.base.CommonModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Date;
import java.sql.Timestamp;

/**
* @author lida
* @date 2022-04-28
*/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("personal_loan")
public class Loan extends CommonModel<Loan> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "借贷id")
    @TableId(type= IdType.ASSIGN_ID)
    private String id;

    @ApiModelProperty(value = "类型")
    @NotBlank
    private String kind;

    private String username;

    @ApiModelProperty(value = "对象")
    @NotBlank
    private String target;

    @ApiModelProperty(value = "金额")
    @NotBlank
    private String num;

    @ApiModelProperty(value = "备注")
    private String remarks;

    @ApiModelProperty(value = "开始时间")
    private Date startTime;

    @ApiModelProperty(value = "最终日期")
    private Date finalTime;

    @TableField(fill= FieldFill.INSERT)
    private Date createTime;

    public void copyFrom(Loan source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
